"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
  _easycom_u_popup2();
}
const _easycom_u_popup = () => "../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  _easycom_u_popup();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    modelValue: { type: Boolean, default: false },
    title: { default: "" },
    subTitle: { default: "" },
    disableCheckPrivacy: { type: Boolean, default: true },
    agreePrivacyId: { default: "agree-btn" }
  },
  emits: ["update:modelValue", "needPrivacyAuthorization", "agree", "disagree"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const initTitle = common_vendor.ref("隐私政策概要");
    const initSubTitle = common_vendor.ref("");
    const initPrivacyContractName = common_vendor.ref("隐私政策");
    function openAgreePrivacy() {
      emit("update:modelValue", true);
    }
    function closeAgreePrivacy() {
      emit("update:modelValue", false);
    }
    function initData() {
      initTitle.value = props.title || initTitle.value;
      initSubTitle.value = props.subTitle || `亲爱的用户，感谢您一直以来的支持!为了更好地保护您的权益，同时遵守相关监管要求，请认真阅读${initPrivacyContractName.value}，特向您说明如下:`;
    }
    function checkPrivacySetting() {
      common_vendor.wx$1.getPrivacySetting({
        success: (res) => {
          if (res.needAuthorization) {
            initPrivacyContractName.value = res.privacyContractName;
            initData();
            if (!props.disableCheckPrivacy) {
              openAgreePrivacy();
            }
          }
        },
        fail: (e) => {
          console.log(e);
        }
      });
    }
    function openPrivacyContract() {
      common_vendor.wx$1.openPrivacyContract({
        success: () => {
        },
        // 打开成功
        fail: (e) => {
          common_vendor.index.$u.toast(`打开失败:${e}`);
        }
        // 打开失败
      });
    }
    function agree(e) {
      const buttonId = e.target.id || "agree-btn";
      emit("agree", buttonId);
      emit("update:modelValue", false);
    }
    function disagree() {
      emit("disagree");
      closeAgreePrivacy();
    }
    common_vendor.onMounted(() => {
      checkPrivacySetting();
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.t(common_vendor.unref(initTitle)),
        b: common_vendor.t(common_vendor.unref(initSubTitle)),
        c: common_vendor.t(common_vendor.unref(initPrivacyContractName)),
        d: common_vendor.o(openPrivacyContract),
        e: common_vendor.o(disagree),
        f: _ctx.agreePrivacyId,
        g: common_vendor.o(agree),
        h: common_vendor.o(closeAgreePrivacy),
        i: common_vendor.p({
          show: _ctx.modelValue,
          round: "20"
        })
      };
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c987c361"]]);
wx.createComponent(Component);
